<template>
  <div>
    <el-table
      style="width: 100%;margin-top: 20px"
      :data="value.skuList"
      size="mini"
      border
      @current-change="handleSelectionChange"
    >
      <el-table-column label="规格" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.sp}}</span>
        </template>
      </el-table-column>

      <el-table-column label="库存" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.stock}}</span>
        </template>
      </el-table-column>
      <el-table-column label="预警值" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.lowStock}}</span>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import {
  updateProduct,
} from "@/api/product";
export default {
  props: {
    value: {
      default: null
    }
  },
  watch: {
    value: {
      handler(newValue, oldValue) {
          if(newValue.skuList== undefined){
              return;
          }
          newValue.skuList.forEach(element => {
              if(element.id == this.value.defualSku){
                  this.selected = element
              }
          });
      },
      immediate: true
    }
  },
  data() {
    return {
      isStopCell: false,
      selected:null
    };
  },

  methods: {

    handleSelectionChange(row) {
      
      if (this.isStopCell==true) {
        this.isStopCell = false;
        return;
      }
      this.selected = row
      this.$emit("cell-click", row);
    },
  }
};
</script>

<style>

  .el-table__body tr:hover > td{
    background-color:#CC3D3D !important;
    color: #FFF;
}

</style>